Revert "ANDROID: incremental-fs: fix mount_fs issue"

This reverts commit 93717b608dd30f9d41b15a72e809238807c68026.

Test: Can now install the same apk twice, and repeated installs are
stable
Bug: 217661925
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I86871c364c17a0d1107b3891a574b72edcf04ea2
(cherry picked from commit d107cd06f26b4d45b1079c7eb857815905198076)
Signed-off-by: Steve Muckle <smuckle@google.com>
diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c
index 84f9932..8d21f6de 100644
--- a/fs/incfs/vfs.c
+++ b/fs/incfs/vfs.c
@@ -393,7 +393,7 @@
 	struct mount_info *mi = get_mount_info(file_superblock(file));
 	bool root;
 
-	if (!dir || !mi) {
+	if (!dir) {
 		error = -EBADF;
 		goto out;
 	}
@@ -1336,9 +1336,6 @@
 	struct dentry *trap;
 	int error = 0;
 
-	if (!mi)
-		return -EBADF;
-
 	error = mutex_lock_interruptible(&mi->mi_dir_struct_mutex);
 	if (error)
 		return error;
@@ -1667,9 +1664,6 @@
 	size_t stored_size;
 	int i;
 
-	if (!mi)
-		return -EBADF;
-
 	if (di && di->backing_path.dentry)
 		return vfs_getxattr(di->backing_path.dentry, name, value, size);
 
@@ -1704,9 +1698,6 @@
 	size_t *stored_size;
 	int i;
 
-	if (!mi)
-		return -EBADF;
-
 	if (di && di->backing_path.dentry)
 		return vfs_setxattr(di->backing_path.dentry, name, value, size,
 				    flags);
@@ -1745,11 +1736,6 @@
 	return vfs_listxattr(di->backing_path.dentry, list, size);
 }
 
-static int incfs_test_super(struct super_block *s, void *p)
-{
-	return s->s_fs_info != NULL;
-}
-
 struct dentry *incfs_mount_fs(struct file_system_type *type, int flags,
 			      const char *dev_name, void *data)
 {
@@ -1760,8 +1746,7 @@
 	struct dentry *incomplete_dir = NULL;
 	struct super_block *src_fs_sb = NULL;
 	struct inode *root_inode = NULL;
-	struct super_block *sb = sget(type, incfs_test_super, set_anon_super,
-				      flags, NULL);
+	struct super_block *sb = sget(type, NULL, set_anon_super, flags, NULL);
 	int error = 0;
 
 	if (IS_ERR(sb))
@@ -1802,18 +1787,13 @@
 	src_fs_sb = backing_dir_path.dentry->d_sb;
 	sb->s_maxbytes = src_fs_sb->s_maxbytes;
 
-	if (!sb->s_fs_info) {
-		mi = incfs_alloc_mount_info(sb, &options, &backing_dir_path);
+	mi = incfs_alloc_mount_info(sb, &options, &backing_dir_path);
 
-		if (IS_ERR_OR_NULL(mi)) {
-			error = PTR_ERR(mi);
-			pr_err("incfs: Error allocating mount info. %d\n", error);
-			mi = NULL;
-			goto err;
-		}
-		sb->s_fs_info = mi;
-	} else {
-		mi = sb->s_fs_info;
+	if (IS_ERR_OR_NULL(mi)) {
+		error = PTR_ERR(mi);
+		pr_err("incfs: Error allocating mount info. %d\n", error);
+		mi = NULL;
+		goto err;
 	}
 
 	index_dir = open_or_create_special_dir(backing_dir_path.dentry,
@@ -1838,22 +1818,21 @@
 	}
 	mi->mi_incomplete_dir = incomplete_dir;
 
+	sb->s_fs_info = mi;
 	root_inode = fetch_regular_inode(sb, backing_dir_path.dentry);
 	if (IS_ERR(root_inode)) {
 		error = PTR_ERR(root_inode);
 		goto err;
 	}
 
+	sb->s_root = d_make_root(root_inode);
 	if (!sb->s_root) {
-		sb->s_root = d_make_root(root_inode);
-		if (!sb->s_root) {
-			error = -ENOMEM;
-			goto err;
-		}
-		error = incfs_init_dentry(sb->s_root, &backing_dir_path);
-		if (error)
-			goto err;
+		error = -ENOMEM;
+		goto err;
 	}
+	error = incfs_init_dentry(sb->s_root, &backing_dir_path);
+	if (error)
+		goto err;
 
 	mi->mi_backing_dir_path = backing_dir_path;
 	sb->s_flags |= SB_ACTIVE;
@@ -1876,9 +1855,6 @@
 	struct mount_info *mi = get_mount_info(sb);
 	int err = 0;
 
-	if (!mi)
-		return err;
-
 	sync_filesystem(sb);
 	err = parse_options(&options, (char *)data);
 	if (err)
@@ -1912,16 +1888,12 @@
 
 	kill_anon_super(sb);
 	incfs_free_mount_info(mi);
-	sb->s_fs_info = NULL;
 }
 
 static int show_options(struct seq_file *m, struct dentry *root)
 {
 	struct mount_info *mi = get_mount_info(root->d_sb);
 
-	if (!mi)
-		return -EBADF;
-
 	seq_printf(m, ",read_timeout_ms=%u", mi->mi_options.read_timeout_ms);
 	seq_printf(m, ",readahead=%u", mi->mi_options.readahead_pages);
 	if (mi->mi_options.read_log_pages != 0) {
diff --git a/fs/incfs/vfs.h b/fs/incfs/vfs.h
index 8876e63a..79fdf24 100644
--- a/fs/incfs/vfs.h
+++ b/fs/incfs/vfs.h
@@ -19,6 +19,7 @@
 {
 	struct mount_info *result = sb->s_fs_info;
 
+	WARN_ON(!result);
 	return result;
 }